﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;

namespace SCCM
{
    public partial class PublicPlot : Skin_Mac
    {
        public PublicPlot(string chartType)
        {
            InitializeComponent();
            //chart1.Series[0].Label = "#VAL";
            //chart1.Series[0].IsValueShownAsLabel = true;
            chart1.ChartAreas[0].AxisX.LabelStyle.Font = new System.Drawing.Font("Tahoma", 7);
            chart1.ChartAreas[0].AxisY.LabelStyle.Font = new System.Drawing.Font("Tahoma", 7);
            chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
            switch (chartType) {
                case "O3":
                case "NO":
                case "NO2":
                    chart1.ChartAreas[0].AxisY.Interval = 4.000;
                    chart1.ChartAreas[0].AxisY.Minimum = 0.000;
                    chart1.ChartAreas[0].AxisY.Maximum = 20.000;
                    break;
                case "CO":
                    chart1.ChartAreas[0].AxisY.Interval = 10.000;
                    chart1.ChartAreas[0].AxisY.Minimum = 0.000;
                    chart1.ChartAreas[0].AxisY.Maximum = 50.000;
                    break;
                case "Tem":
                    chart1.ChartAreas[0].AxisY.Interval = 10;
                    chart1.ChartAreas[0].AxisY.Minimum = -10;
                    chart1.ChartAreas[0].AxisY.Maximum = 50;
                    break;
                case "RH":
                    chart1.ChartAreas[0].AxisY.Interval = 0.20;
                    chart1.ChartAreas[0].AxisY.Minimum = 0.00;
                    chart1.ChartAreas[0].AxisY.Maximum = 1.00;
                    chart1.ChartAreas[0].AxisY.LabelStyle.Format = "0%";//格式化，为了显示百分号
                    break;
                case "Ato":
                    chart1.ChartAreas[0].AxisY.Interval = 10;
                    chart1.ChartAreas[0].AxisY.Minimum = 80;
                    chart1.ChartAreas[0].AxisY.Maximum = 130;
                    break;
            }

            chart1.ChartAreas[0].BackColor = Color.Black;
            chart1.Series[0].Color = Color.Yellow;
            chart1.Series[0].BorderWidth = 2;
            chart1.Series[0].IsValueShownAsLabel = true;
            chart1.Series[0].LabelForeColor = Color.Green;
            chart1.Series[0].LabelBorderWidth = 2;
           
            this.timer1.Start();
            this.timer1.Interval = 1000;
        }
        private MainWindow form;
        private List<String> xval;
        private List<double> yval;
        public void SetForm(MainWindow form)
        {
            this.form = form;
        }
        public void SetTile(String title)
        {
            this.Text = title+this.Text;
        }
        public void SetX(List<String> x)
        {
            this.xval = x;
        }
        public void SetY(List<double> y)
        {
            this.yval = y;
        }
        public void  ValidateData()
        {
            chart1.Series[0].Points.DataBindXY(xval, yval);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //yval = this.form.getYNO2();
            ValidateData();
        }
    }
}
